import 'package:sainbainu/common/utils/util.dart';

class MessageCommentListResponse {
  List<MessageCommentResponse> rows;
  int total;

  MessageCommentListResponse({
    required this.rows,
    required this.total,
  });

  factory MessageCommentListResponse.fromJson(Map<String, dynamic> json) =>
      MessageCommentListResponse(
        total: json['total'] as int,
        rows: (json['rows'] as List)
            .map((e) => MessageCommentResponse.fromJson(e))
            .toList(),
      );
}

class MessageCommentResponse {
  int? customerId;
  String? customerName;
  String? avatar;
  String? operateMsg;
  String? text;
  String? image;
  String? video;
  String? videoCover;
  String? audio;
  int? audioDuration;
  String? resourceType;
  int? resourceId;
  int? noteId;
  int? commentId;
  String? commentText;
  String? commentImage;
  String? commentAudio;
  int? commentAudioDuration;
  String? uniqueTag;
  int officialFlag;
  String? officialName;

  MessageCommentResponse({
    this.customerId,
    this.customerName,
    this.avatar,
    this.operateMsg,
    this.text,
    this.image,
    this.video,
    this.videoCover,
    this.audio,
    this.audioDuration,
    this.resourceType,
    this.resourceId,
    this.noteId,
    this.commentId,
    this.commentText,
    this.commentImage,
    this.commentAudio,
    this.commentAudioDuration,
    this.uniqueTag,
    this.officialFlag = 0,
    this.officialName,
  });

  factory MessageCommentResponse.fromJson(Map<String, dynamic> json) {
    return MessageCommentResponse(
      customerId: json['customerId'] as int?,
      customerName: json['customerName'] as String?,
      avatar: json['avatar'] as String?,
      operateMsg: json['operateMsg'] as String?,
      text: json['text'] as String?,
      image: json['image'] as String?,
      video: json['video'] as String?,
      videoCover: json['videoCover'] as String?,
      audio: json['audio'] as String?,
      audioDuration: json['audioDuration'] as int?,
      resourceType: json['resourceType'] as String?,
      resourceId: json['resourceId'] as int?,
      noteId: json['noteId'] as int?,
      commentId: json['commentId'] as int?,
      commentText: json['commentText'] as String?,
      commentImage: json['commentImage'] as String?,
      commentAudio: json['commentAudio'] as String?,
      commentAudioDuration: json['commentAudioDuration'] as int?,
      uniqueTag: Util.generateRandomString(),
      officialFlag: (json['officialFlag'] as int?) ?? 0,
      officialName: json['officialName'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'customerId': customerId,
        'customerName': customerName,
        'avatar': avatar,
        'operateMsg': operateMsg,
        'text': text,
        'image': image,
        'video': video,
        'videoCover': videoCover,
        'audio': audio,
        'audioDuration': audioDuration,
        'resourceType': resourceType,
        'resourceId': resourceId,
        'noteId': noteId,
        'commentId': commentId,
        'commentText': commentText,
        'commentImage': commentImage,
        'commentAudio': commentAudio,
        'commentAudioDuration': commentAudioDuration,
        'officialFlag': officialFlag,
        'officialName': officialName,
      };
}
